﻿using System;
using FineUI;
using OnlineTestModel;

namespace OnlineTestUI.BackManager
{
    public partial class _default : System.Web.UI.Page
    {
        #region Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["teacher"] == null)
            {
                PageContext.Redirect("login.aspx");
            }
            else
            {
                Teachers s = (Teachers)Session["teacher"];
                if (!IsPostBack)
                {
                    BindLeftTree();
                }
            }
        }

        #endregion

        private void BindLeftTree(string menuType)
        {
            if (menuType == "Test")
            {
                XmlDataSource1.DataFile = "./data/menuTest.xml";
                PageContext.RegisterStartupScript("selectMenu('test');");
               
            }
            else if (menuType == "sys")
            {
                XmlDataSource1.DataFile = "./data/menuSYS.xml";
                PageContext.RegisterStartupScript("selectMenu('menu-sys');");
            }
            else if (menuType == "sms")
            {
                XmlDataSource1.DataFile = "./data/menusms.xml";
                PageContext.RegisterStartupScript("selectMenu('menu-sms');");
            }

            BindLeftTree();
        }

        private void BindLeftTree()
        {
            leftTree.DataSource = XmlDataSource1;
            leftTree.DataBind();
        }

        #region Events

        protected void lbtnTest_Click(object sender, EventArgs e)
        {
            BindLeftTree("Test");
        }


        protected void lbtnSYS_Click(object sender, EventArgs e)
        {
            BindLeftTree("sys");
        }


        protected void lbtnSMS_Click(object sender, EventArgs e)
        {
            BindLeftTree("sms");
        }

        #endregion
    }

}